package top.superflow.db.orientdb

import top.superflow.db.api.DBIndex
import top.superflow.exception.RequestUnsupportedException
import com.orientechnologies.orient.core.index.OIndex
import top.superflow.verify.Ensure

import scala.collection.JavaConverters._
import scala.collection.immutable.List
import scala.collection.mutable.ListBuffer

class OrientIndex (realIndex : OIndex[_]) extends DBIndex
                                       with Ensure{
  notNull(realIndex, "The real Orient Index should not be null.")
  
  
  val columns : ListBuffer[String] = ListBuffer()
  columns ++= realIndex.getDefinition.getFields.asScala
  this.fieldList = columns.toList
  this.unique = realIndex.isUnique()
  this.automatic = realIndex.isAutomatic()

  this.name = realIndex.getName
//  this.fieldList = List.
  override def containsKey(columnName: String): Boolean = {
    return realIndex.contains(columnName)
  }
  
}